package part19;

/**
 * @author wcj
 * @Date 2021/6/5 17:14
 * @Version 1.0
 */
public class Part193 {

    Signal color = Signal.RED;

    public void change() {
        switch (color) {
            case RED:
                color = Signal.GREEN;
                break;
            case GREEN:
                color = Signal.YELLOW;
                break;
            case YELLOW:
                color = Signal.RED;
                break;
            default:
                System.out.println("哈哈哈");
        }
    }

    @Override
    public String toString() {
        return "the traffic color is :" + color;
    }

    /**
     * 枚举在switch中的使用，switch的项只能是整数值，然而枚举天生就和switch进行了绑定一样
     *
     * @param args
     */
    public static void main(String[] args) {
        Part193 part193 = new Part193();
        for (int i = 0; i < 7; i++) {
            System.out.println(part193);
            part193.change();
        }
    }
}

enum Signal {
    GREEN,
    YELLOW,
    RED,
}
